﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ProductManService
{
    public class ProductRepository
    {
        public ProductManagementDataContext DB { get; set; }

        public ProductRepository()
        {
            DB = new ProductManagementDataContext();
            DB.DeferredLoadingEnabled = false;
        }
        public Category GetCategoryByProductId(int prod_Id)
        {
            return GetProductByID(prod_Id).Category;
        }

        public Product GetProductByID(int prod_Id)
        {
            var prod = (from p in DB.Products
                        where p.Id == prod_Id
                        select p).FirstOrDefault<Product>();
            return prod;
        }
    }
}